package com.beyondsoft.sabg.edu.utils;

import com.beyondsoft.sabg.edu.model.vo.core.SimpleResponseVO;

/**
 * @Author Mo cr
 * @Date 2023/8/7
 */
public class ResponseUtil {
    public static SimpleResponseVO success() {
        return createSimpleResponseVO(true);
    }

    public static SimpleResponseVO failed() {
        return createSimpleResponseVO(false);
    }

    public static SimpleResponseVO failed(String messageId, String message) {
        return createSimpleResponseVO(false)
                .withPropertyMessage(messageId, message);
    }

    public static SimpleResponseVO failed(String message) {
        SimpleResponseVO SimpleResponseVO = createSimpleResponseVO(false);
        SimpleResponseVO.setMessage(message);
        return SimpleResponseVO;
    }

    public static SimpleResponseVO createSimpleResponseVO(boolean success) {
        return createSimpleResponseVO(success, null, null);
    }

    public static SimpleResponseVO createSimpleResponseVO(boolean success, String code) {
        return createSimpleResponseVO(success, code, null);
    }

    public static SimpleResponseVO createSimpleResponseVO(boolean success, String code, Object data) {
        SimpleResponseVO r = new SimpleResponseVO();
        r.setSuccess(success);
        r.setMessage(code);
        r.setData(data);
        return r;
    }

}
